<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
 <head>
  <title>WireIt Guide</title>
	<meta name="author" content="Eric Abouaf" />
	<meta name="copyright" content="Copyright 2009 Eric Abouaf" />
	<meta name="keywords" content="wireit,javascript,library,pipes,visualization,yui,programming,canvas,wire,wires,framework,webdev,ajax,ui,web,graphics,graph,graphs,opensource,tools" />
	<meta name="description" content="WireIt is an open-source javascript library to create web wirable interfaces for dataflow applications, visual programming languages or graphical modeling." />
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<link rel="alternate" type="application/rss+xml" title="WireIt blog" href="http://javascript.neyric.com/blog/feed/" />
	<link rel="shortcut icon" type="images/x-icon" href="res/favicon.ico" />
	<link rel="stylesheet" type="text/css" href="res/style.css" />
	<link rel="stylesheet" type="text/css" href="res/guide.css" />

	<link rel="stylesheet" type="text/css" href="res/SyntaxHighlighter/shCore.css" />	
	<link type="text/css" rel="stylesheet" href="res/SyntaxHighlighter/shThemeDefault.css" id="shTheme"/>
	
	<script type="text/javascript" src="res/SyntaxHighlighter/shCore.js"></script>
	<script type="text/javascript" src="res/SyntaxHighlighter/shBrushJScript.js"></script>
	<script type="text/javascript" src="res/SyntaxHighlighter/shBrushXml.js"></script>
	<script type="text/javascript" src="res/SyntaxHighlighter/shBrushCss.js"></script>
	<script type="text/javascript">SyntaxHighlighter.config.clipboardSwf = 'res/SyntaxHighlighter/clipboard.swf';SyntaxHighlighter.all();</script>
	
	
	
 </head>

 <body>
	
<div id='headbar'>
		
	<ul class="navigation" style=" position: absolute; margin: 6px 0 0 380px;">
		<li><a href="index.html">Home</a></li>	
		<li><a href="http://github.com/neyric/wireit/">GitHub[Git]</a></li>
		<li><a href="http://github.com/neyric/wireit/issues">Issues</a></li>
		<li><a href="guide.html">Guide</a></li>
		<li><a href="doc/index.html">API Documentation</a></li>		
		<li><a href="http://javascript.neyric.com/blog/category/wireit/">Blog</a> 
			  <a href="http://javascript.neyric.com/blog/feed/"><img src="doc/rss.png" border="0"/></a></li>	
		<li><a href="http://groups.google.com/group/wireit/">Forums</a></li>
	</ul>
	
	<div style="position: absolute; top: 80px; left: 750px; font-size: 90%; line-height: 30px;">
		<img src='http://www.twitter.com/favicon.ico' alt="twitter" /> follow <a href="http://twitter.com/wireit">WireIt on Twitter</a><br />
		<img src="http://delicious.com/favicon.ico"> bookmark on <a href="http://del.icio.us/url/651a56650c753830645ecf46fb036db6">Del.icio.us</a><br />
		<img src='http://github.com/favicon.ico' alt="twitter" /> follow <a href="http://github.com/neyric/wireit/tree/master"> on GitHub</a>
	</div>

</div>
	
<center>
	
<div style="text-align: left; width: 70%;">
	
	
	
<!-- START OF THE GUIDE -->
	

<h1>WireIt Guide</h1>

<p>This guide tries to centralize everything that has been written on WireIt. If you think something is missing or need better explanation, please contact us through the <a href="http://groups.google.com/group/wireit/">forum</a>. Being written by a french, help in finding typos, technical errors, or poorly worded sentences is greatly appreciated.</p>

<h1>Index</h1>
	
<div id="index"></div>

<div id='book'>
	<ol class="topLevel">
		<li>
			<a href="#overview"><span>Overview</span></a>
			
			<ol class="secondLevel">
	    		<li><a href="#presentation">Presentation</a></li>
				<li><a href="#components">Components/Widgets</a></li>
	    		<li><a href="#WireItApplication">WireIt applications</a></li>
				<li><a href="#directoryStructure">Directory structure</a></li>
			</ol>
		</li>	
		
		<li>
			<a href="#GettingStarted"><span>Getting Started</span></a>

			<ol class="secondLevel">
	    		<li><a href="#installation">Installation</a></li>
				<li><a href="#WiringEditorInstallation">WiringEditor installation</a></li>
	    		<li><a href="#firstApp">Create Your First WireIt Application</a></li>
			</ol>
		</li>
		
		<li>
			<a href="#visualLanguage"><span>Create your visual language</span></a>
			
			<ol class="secondLevel">
				<li><a href="#visualLanguageDefinition">Visual Language Definition</a></li>
				<li><a href="#moduleDefinition">Module Definition</a></li>
				<li><a href="#BaseContainer">Using the basic Container</a></li>
				<li><a href="#InOutContainer">Using InOutContainer</a></li>
				<li><a href="#FormContainer">Using FormContainer</a></li>
				<li><a href="#ImageContainer">Using ImageContainer</a></li>
				<li><a href="#propertiesForm">Edit the "Properties" form</a></li>
			</ol>
		</li>
		
		
		<li>
			<a href="#adapters"><span>Adapters - Connecting to another database or backend</span></a>

			<ol class="secondLevel">
				<li><a href="#adaptersIntroduction">Introduction</a></li>
				<li><a href="#adaptersConfiguration">Configuring the adapter</a></li>
				<li><a href="#ajaxAdapter">Ajax adapter</a></li>
				<li><a href="#jsonRPCAdapter">Json-RPC Adapter</a></li>
				<li><a href="#gearsAdapter">Gears adapter</a></li>
	    		<li><a href="#adaptersCreation">Create an adapter</a></li>
			</ol>
		</li>
		
		<li>
			<a href="#advancedTopics"><span>Advanced Topics</span></a>

			<ol class="secondLevel">
				<li><a href="#outputFormat">WiringEditor ouput format</a></li>
				<li><a href="#stylingContainers">Styling containers</a></li>
				<li><a href="#autoload">WiringEditor autoload feature</a></li>
				<li><a href="#mouseEvents">Handling Wire mouse events</a></li>
				<li><a href="#createContainers">Creating new Containers / Extending existing containers</a></li>
				<li><a href="#production">notes on production</a></li>
			</ol>
		</li>
		
		<li>
			<a href="#moreInformation"><span>More information</span></a>
			
			<ol class="secondLevel">
				<li><a href="#examples">All examples</a></li>
				<li><a href="#apiReferences">API References</a></li>
				<li><a href="#otherResources">Other resources</a></li>
				<li><a href="#projects">WireIt-based projects</a></li>
				<li><a href="#contribute">Contribute</a></li>
				<li><a href="#roadmap">Roadmap</a></li>
			</ol>
		</li>
		
	</ol>
</div>
	
	
	
	
	
	

<a name="overview"><h1>Overview</h1></a>

<a name="presentation"><h2>Presentation</h2></a>

<p>WireIt is an open-source javascript library to create <i>web wirable interfaces</i> for <b>dataflow applications</b>, <b>visual programming languages, graphical modeling,</b> or <b>graph editors</b>.</p>

<p>WireIt is tested on all <a href="http://developer.yahoo.com/yui/articles/gbs/">A-Grade Browsers</a>, although it might work with older versions of browsers and platforms. Please report your issues with specific browsers in <a href="http://groups.google.com/group/wireit/">the forum</a>.</p> 

<p>It uses the <a href="http://developer.yahoo.com/yui/">YUI library</a> (2.7.0) for DOM and events manipulation, and <a href="http://excanvas.sourceforge.net/">excanvas</a> for IE support of the canvas tag.</p>


<p>The code for Wireit is provided under a <a href="license.txt">MIT license</a>.</p>


<a name="components"><h2>Components/Widgets</h2></a>

<p>Here are the main widget classes :</p>
	
<ul>
	<li>Wire - create wires in browsers</li>
	<li>Terminal - wire endpoints and edition widget</li>
	<li>Container - general "box" containing one or more terminals</li>
	<li>Layer - handle multiple containers and wires</li>
</ul>

<p>Different types of Container are provided :</p>
<ul>
	<li>InOutContainer - simple module with named inputs and outputs</li>
	<li>FormContainer - build form containers based on <a href="http://javascript.neyric.com/inputex/">inputEx</a> forms</li>
	<li>ImageContainer - use images as graph nodes</li>
</ul>

<p>You can create your own container by subclassing the base <i>Container</i> class, and still benefit from the drop-in use of the WiringEditor in your web application.</p>



<a name="WireItApplication"><h2>WireIt applications</h2>	

<p>WireIt provides another useful component: the <b>WiringEditor</b>, a single-page editor for your <i>visual language</i>.</p>

<p>You create a simple html page, import WireIt widgets and WiringEditor, define your visual language using a JSON configuration and a full-page editor is built into the browser to use your language.</p>

<p>The WiringEditor requires a connection to a database to use save/load features. You can customize it using adapters. A default adapter is provided, which uses JSON-RPC through ajax calls, and a PHP/MySQL backend.</p>


<a name="directoryStructure"><h2>Directory structure</h2></a>

<table>
	<thead>
		<tr>
			<th>file or directory</th>
			<th></th>
		</tr>
	</thead>
	<tbody>
		<tr>
			<td>backend/</td>
			<td>Contains backend (server-side) code for the WiringEditor</td>
		</tr>
		<tr>
			<td>build/</td>
			<td>Contains the minified javascript and build scripts</td>
		</tr>
		<tr>
			<td>css/</td>
			<td>Contains the css WireIt components</td>
		</tr>
		<tr>
			<td>doc/</td>
			<td>Auto-generated API documentation</td>
		</tr>
		<tr>
			<td>examples/</td>
			<td>Examples or applications that are part of the library</td>
		</tr>
		<tr>
			<td>images/</td>
			<td>WireIt images</td>
		</tr>
		<tr>
			<td>index.html</td>
			<td>WireIt Home page</td>
		</tr>
		<tr>
			<td>INSTALL.txt</td>
			<td>Installation instructions</td>
		</tr>
		<tr>
			<td>js/</td>
			<td>javascript sources</td>
		</tr>
		<tr>
			<td>lib/</td>
			<td>Librairies required by WireIt</td>
		</tr>
		<tr>
			<td>license.txt</td>
			<td>Open-source license details</td>
		</tr>
		<tr>
			<td>README.txt</td>
   			<td>This file</td>
		</tr>
		<tr>
			<td>VERSION.txt</td>
			<td>The change log</td>
		</tr>
</tbody>
</table>




<a name="GettingStarted"><h1>Getting Started</h1></a>





<a name="installation"><h2>Installation</h2></a>

<p>WireIt is mostly a bunch of static javascript, css, and image files, so you can just <a href="http://javascript.neyric.com/wireit">download the library</a> and put the files in your project library directory.</p>
	
<p>However, the WiringEditor requires a database connection to use the save/load features. (see <a href="#WiringEditorInstallation">WiringEditor installation</a>)</p>


<p class="advanced">You could also clone the <a href="http://github.com/neyric/wireit/tree/master">development repository</a> to get the edge version.</p>

<p class="advanced">In a production environment, documentation and examples are not necessary. More on this in <a href="#production">production</a>.</p>






<a name="WiringEditorInstallation"><h3>WiringEditor installation</h3></a>

<p>The WiringEditor requires a database connection to use the save/load features. <br />
   The database connection can be adapted to your project though <a href="#adapters">adapters</a>.</p> 

<p>Adapters themselves don't require any particular installation, however, they are connected to a <i>backend</i>, which often require a specific server environment.</p>

<p>Please refer to the <a href="#adapters">adapters documentation</a> to install the associated backends.</p>
	
<p class="advanced">You can <a href="#adaptersCreation">create your own adapters</a>.</p>


<a name="firstApp"><h2>Create Your First WireIt Application</h2></a>

<p>Depending on which default adapter you decided to use, copy the examples/gearsAdapter/ or examples/WiringEditor/ files into your project directory.</p>

<p>Edit the index.html file you copied to check that the paths to javascript and css files are correct. (You might want to create your project directory directly in the examples/ folder so that the paths remain unchanged.)</p>

<p>Launch the index.html file in your browser. You're ready to create your <a href="#visualLanguage">visual language</a>.</p>






<a name="visualLanguage"><h1>Create your visual language</h1></a>

<a name="visualLanguageDefinition"><h2>Visual Language Definition</h2></a>

<p>The visual language is defined in a JSON format :</p>

<pre class="brush:js">
	var myLanguage = {
		
		// Set a unique name for the language
		languageName: "myLanguage",

		modules: [
			// List of module type definitions
		]
	};
</pre>




<a name="moduleDefinition"><h2>Module Definition</h2></a>

<p>Here is the skeleton of a module definition :</p>

<pre class="brush:js">
{
 "name": "moduleName",
 "container": {
	
	// which container class to use
	"xtype":"WireIt.InOutContainer",
	
	// Depends of the container
	"inputs": ["text1", "text2", "option1"],
	"outputs": ["result", "error"]
  }
}
</pre>


<p>To declare a module using a different <i>Container</i> class, you'll have to set the container <i>xtype</i> property.</p>

<p class="advanced">The xtype property is a string representing the class. This had to be a string to remain JSON compliant.</p>

<p>Of course, you can use containers provided in WireIt (ImageContainer, FormContainer, InOutContainer), or a <a href="#customContainer">custom container</a>.</p>


<a name="BaseContainer"><h2>Using the basic Container</h2></a>


<p>Set "xtype": "WireIt.Container" (optional). The parameters are :</p>

<ul>
	<li><i>icon</i> - url of the icon (relative or absolute)</li>
	<li><i>terminals</i> - list of terminals configuration</li>
</ul>

<pre class="brush:js">
    {
       "name": "demoModule",
       "container": {
    		"xtype":"WireIt.Container", 

			"icon": "../../res/icons/application_edit.png",
    		"terminals": [
    			{"name": "_INPUT1", "direction": [-1,0], "offsetPosition": {"left": -3, "top": 2 }},
    			{"name": "_INPUT2", "direction": [-1,0], "offsetPosition": {"left": -3, "top": 37 }},
    			{"name": "_OUTPUT", "direction": [1,0], "offsetPosition": {"left": 103, "top": 20 }}
    		]
    	}
    }
</pre>



<a name="InOutContainer"><h2>Using InOutContainer</h2></a>

<p>Set "xtype": "WireIt.InOutContainer". Additional parameters are :</p>

<ul>
	<li><i>inputs</i> - list of inputs as strings</li>
	<li><i>outputs</i> - list of outputs as strings</li>
</ul>

<p>Example: </p>

<pre class="brush:js">
{
 "name": "InOut test",
 "container": {
	"xtype":"WireIt.InOutContainer",
	"inputs": ["text1", "text2", "option1"],
	"outputs": ["result", "error"]
  }
}
</pre>


<a name="FormContainer"><h2>Using FormContainer</h2></a>

<p>Set "xtype": "WireIt.FormContainer". Additional parameters are all those used in inputEx.Group. (see <a href="http://javascript.neyric.com/inputex/">inputEx</a>)</p>


<pre class="brush:js">
	{
	  "name": "MyModule",
	  "container": {
		"xtype": "WireIt.FormContainer",
		
		// inputEx options :
		"title": "WireIt.FormContainer demo",
		"collapsible": true,
		"fields": [ 
			{"type": "select", "inputParams": {"label": "Title", "name": "title", "selectValues": ["Mr","Mrs","Mme"] } },
			{"inputParams": {"label": "Firstname", "name": "firstname", "required": true } }, 
			{"inputParams": {"label": "Lastname", "name": "lastname", "value":"Dupont"} }, 
			{"type":"email", "inputParams": {"label": "Email", "name": "email", "required": true, "wirable": true}}, 
			{"type":"boolean", "inputParams": {"label": "Happy to be there ?", "name": "happy"}}, 
			{"type":"url", "inputParams": {"label": "Website", "name":"website", "size": 25}} 
		],
		"legend": "Tell us about yourself..."
		
	  }
	}
</pre>	


<a name="ImageContainer"><h2>Using ImageContainer</h2></a>

<p>Set "xtype": "WireIt.ImageContainer". Additional parameters are :</p>

<ul>
	<li><i>image</i> - url of the image (relative or absolute)</li>
</ul>

<pre class="brush:js">
    {
       "name": "AND gate",
       "container": {
    		"xtype":"WireIt.ImageContainer", 
    		"image": "../logicGates/images/gate_and.png",
    		"terminals": [
    			{"name": "_INPUT1", "direction": [-1,0], "offsetPosition": {"left": -3, "top": 2 }},
    			{"name": "_INPUT2", "direction": [-1,0], "offsetPosition": {"left": -3, "top": 37 }},
    			{"name": "_OUTPUT", "direction": [1,0], "offsetPosition": {"left": 103, "top": 20 }}
    		]
    	}
    }
</pre>





<a name="propertiesForm"><h2>Edit the "Properties" form</h2></a>

<p>To add properties to the <i>Wirings</i>, we configure the <i>propertiesFields</i> property of the language definition.<br />
   This property defines the fields as they will appear in the "Properties" form on the right in the WiringEditor.</p>

<p>The form is created using the <a href="http://javascript.neyric.com/inputex/">inputEx form library</a>. The <i>propertiesFields</i> array is directly used to instantiate a inputEx.Group class. Please refer to inputEx documentation to learn how to configure your fields.</p>

<p>When you use the save/load fetures of the WiringEditor, the form values are automatically saved within your <i>wirings</i> before being sent back to the server.</p>

<pre class="brush:js">
	var demoLanguage = {
		
		languageName: "meltingpotDemo",
		
		// inputEx fields for pipes properties
		propertiesFields: [
			// default fields (the "name" field is required by the WiringEditor):
			{"type": "string", inputParams: {"name": "name", label: "Title", typeInvite: "Enter a title" } },
			{"type": "text", inputParams: {"name": "description", label: "Description", cols: 30} },

			// Additional fields
			{"type": "boolean", inputParams: {"name": "isTest", value: true, label: "Test"}},
			{"type": "select", inputParams: {"name": "category", label: "Category", selectValues: ["Demo", "Test", "Other"]} }
		],

		modules: [
			//...
		]
	};
</pre>

<p class="advanced">The HiddenField can be used to store additional wirings informations.</p>









<a name="adapters"><h2>Adapters - Connecting to another database or backend</h2></a>

<a name="adaptersIntroduction"><h2>Introduction</h2></a>

<p>Adapters are used by the WiringEditor to provide the loading/saving features. It makes it easy to "plug" the WiringEditor into your application. They usually connect to a database of some kind through Ajax calls to store the wirings and bring them back.</p>


<p>WireIt provides default adapters to get you started :</p>


<ul>
	<li><a href="#ajaxAdapter">Ajax Adapter (no backend provided)</a></li>
	<li><a href="#jsonRPCAdapter">Json-RPC Adapter + a sample PHP/MySQL backend</a></li>
	<li><a href="#gearsAdapter">Gears Adapter (no backend required)</a></li>
</ul>
	


<a name="adaptersConfiguration"><h2>Configuring the adapter</h2></a>

<pre class="brush:js">
	
	// Override adapter default parameters
	WireIt.WiringEditor.adapters.MyAdapter.config.configParam1 = value1;
	
	// Instantiate the WiringEditor with a custom adapter
	new WireIt.WiringEditor({
		...
		adapter: WireIt.WiringEditor.adapters.MyAdapter
		...
	})

</pre>	

	
	
<a name="ajaxAdapter"><h2>Ajax Adapter</h2></a>

<p>This adapter is the general way to connect to a custom backend through Ajax (or XHR) calls. It uses a JSON representation.</p>

<p>You can use it to connect to a REST resource store or any HTTP-based RPC backend.</p>

<p>The <a href="examples/ajaxAdapter/">ajaxAdapter example</a> connects to a fake backend (the queried URLs are static files), but demonstrate how to configure the adapter :</p>

<pre class="brush:js">
	
	WireIt.WiringEditor.adapters.Ajax.config = 	{
		saveWiring: {
			method: 'GET',
			// The url can be hard-coded
			url: 'fakeSaveDelete.json'
		},
		deleteWiring: {
			method: 'GET',
			/**
			 * 'url' can also be a function that returns the URL as a string.
			 * For exemple, to connect to a REST store, you might want to send a DELETE /resource/wirings/moduleName
			 * (moduleName is present in the "value" parameter)
			 */
			url: function(value) {
				return "fakeSaveDelete.json";
			}
		},
		listWirings: {
			method: 'GET',
			url: 'listWirings.json'
		}
	};
</pre>




<a name="jsonRPCAdapter"><h2>Json-RPC Adapter</h2></a>

<p>This adapter uses Ajax calls as the previous one, but wraps http requests in a JSON-RPC envelope.</p>

<p>This adapter is used in the <a href="examples/WiringEditor/">WiringEditor demo</a>.</p>

<p>It is connected to a sample PHP/MySQL backend, which requires the following installtion steps :</p>

<ul>
	<li>copy the backend/php directory to your wireit directory</li>
	<li>edit the script with your database access config (backend/php/WiringEditor.php)</li>
	<li>make sure the backend files are accessible by your webserver and that the php module is loaded </li>
</ul>

<p>The JSON-RPC adapter configuration resides in the single service url :</p>

<pre class="brush:js">
	WireIt.WiringEditor.adapters.JsonRpc.config.url = '/my/json-rpc/serviceUrl';
</pre>



<a name="gearsAdapter"><h2>Gears Adapter</h2></a>

<p>This adapter uses the <i>database</i> component of Google Gears to store the <i>wirings</i> in a SQLite table <b>client-side</b> (in the browser).</p>

<p>This adapter is very useful for prototyping your project, since it can be used without any server installation.</p>

<p>To use this adapter, you must install <a href="http://gears.google.com">google gears</a>.</p>

<p>A demo of this adapter is showed in the <a href="examples/gearsAdapter/">gears adapter example</a>.</p>

<p>This adapter doesn't have any noticeable configuration except <i>WireIt.WiringEditor.adapters.Gears.config.dbName</i> which contains the gears database name (default is 'database-test').</p>

<p class="advanced">The gears adapter already includes gears-init.js</p>


<a name="adaptersCreation"><h2>Create an adapter</h2></a>

<p>Why would you build your own ?</p>

<ul>
	<li>You use a different server-side language</li>
	<li>You probably use a framework to develop your website, which provides its own models (ex: Django,Rails,Symfony,...)</li>
	<li>Convert the wirings into another workflow model. (ex: XProc XML)</li>
</ul>

<p>Here is the skeleton of an adapter :</p>

<pre class="brush:js">

WireIt.WiringEditor.adapters.MyAdapter = {
	
	// adapter default options
	config: {
		// ...
	},

	// Initialization method called by the WiringEditor
	init: function() {
		
	},

	/**
	 * save/list/delete asynchronous methods
	 */
	saveWiring: function(val, callbacks) {
		// ...
		// don't forget to call the callbacks !
	},

	deleteWiring: function(val, callbacks) {
		// ...
		// don't forget to call the callbacks !
	},

	listWirings: function(val, callbacks) {
		// ...
		// don't forget to call the callbacks !
	}

	// + private methods or properties
};

})();
</pre>

<p>The main three methods use asynchronous callbacks to push back the results to the WiringEditor. Here is the structure of the callbacks that are passed to these methods : </p>

<pre class="brush:js">
	var callbacks = {
		success: function() {
		},
		failure: function() {
		},
		scope: this
	};
</pre>


<p>To call the callbacks, in a synchronous way, use something like :</p>

<pre class="brush:js">
	function(val, callbacks) {
		
		if(everythingGoesFine) {
			callbacks.success.call(callbacks.scope, results);
		}
		else {
			callbacks.failure.call(callbacks.scope, results);
		}
		
	}
</pre>


<p>The asynchronous pattern is particularly useful for ajax-based adapters. Here is an example with YUI :</p>

<pre class="brush:js">
	function(val, callbacks) {
		
		YAHOO.util.Connect.asyncRequest('POST', 'myUrl', {
			success: function(r) {
				//...
				
				callbacks.success.call(callbacks.scope, results);
			},
			failure: function(r) {
				callbacks.failure.call(callbacks.scope, error);
			}
		});
		
	}
</pre>




<a name="advancedTopics"><h1>Advanced Topics</h1></a>



<a name="outputFormat"><h2>WiringEditor ouput format</h2></a>

<p>First, here is the JSON output of the WiringEditor :</p>

<pre class="brush:js">
var working = {
	"modules":[
		{
			"config":{
				"position":[166,195],
				"xtype":"WireIt.ImageContainer"
			},
			"name":"AND gate",
			"value":{}
		},
		{
			"config":{
				"position":[454,271],
				"xtype":"WireIt.ImageContainer"
			},
			"name":"AND gate",
			"value":{}
		},
		{
			"config":{
				"position":[149,403],
				"xtype":"WireIt.ImageContainer"
			},
			"name":"AND gate",
			"value":{}
		}
	],

	"wires":[
		{
			"src":{"moduleId":0,"terminal":"_OUTPUT"},
			"tgt":{"moduleId":1,"terminal":"_INPUT1"}
		},
		{
			"src":{"moduleId":2,"terminal":"_OUTPUT"},
			"tgt":{"moduleId":1,"terminal":"_INPUT2"}
		}
	],
	
	"properties":{	
		"name":"demo",
		"description":"",
		"isTest":true,
		"category":"Demo"
	}
};
</pre>

<p>First comes the list of instantiated modules. The <i>name</i> is set to the module name, <i>config.xtype</i> indicates the container class, <i>config.position</i> is pretty self-explanatory, and <i>value</i> contains the exported value for this instance (in this case it is empty, but for a FormContainer, it will contain the form value.)</p>

<p>Secondly, the wires instances, composed of a <i>src</i> (source) terminal and a <i>tgt</i> (target) terminal.<br /> 
   Each terminal is referenced by its moduleId (module index in the above definition) and its name (terminal).</p>

<p>Finally, the <i>properties</i> object contains the value of the "Properties" form on the right of the editor.</p>

<p class="advanced">The examples store directly the JSON in a TEXT column in the database. Almost all programming languages provide built-in JSON stringify/parse methods, so you can parse this tree to convert to another format.</p>


<a name="stylingContainers"><h2>Styling containers</h2></a>

<p>The WiringEditor adds a CSS class for each module instance in your layer: <b>WiringEditor-module-<i>moduleName</i></b>.</p>

<p>You can therefore style all the descending structure using cascaded style sheets. <br />
   Here is an exemple for the "comment" module of the <a href="examples/WiringEditor/">WiringEditor demo</a>.</p>

<pre class="brush:css">
	
/* Comment Module */
div.WireIt-Container.WiringEditor-module-comment { 
	width: 200px; 
}
div.WireIt-Container.WiringEditor-module-comment div.body { 
	background-color: #EEEE66; 
}
div.WireIt-Container.WiringEditor-module-comment div.body textarea { 
	background-color: transparent; font-weight: bold; border: 0; 
}

</pre>



<a name="autoload"><h2>WiringEditor autoload feature</h2></a>

<p>The WiringEditor has an option called <i>autoload</i>. <br />
   This is a parameter passed in the URL that tells the WiringEditor which <i>wiring</i> to open when the editor is displayed.</p>

<pre>
	http://myhost.com/editor/?autoload=myWiring
</pre>

<p>For example, here is a direct link to the "guideAutoloadDemo" wiring of the WiringEditor example :<br />
	<a href="examples/WiringEditor/?autoload=guideAutoloadDemo">examples/WiringEditor/?autoload=guideAutoloadDemo</a></p>

<a name="mouseEvents"><h2>Handling Wire mouse events</h2></a>

<p>There are two methods to handle wire mouse events :</p>

<ul>
	<li>
		<p>Listen to wire events (recommanded)</p>
		
		<pre class="brush:js">
		wire.eventMouseIn.subscribe(wireRed, wire, true);
		wire.eventMouseOut.subscribe(wireBlue, wire, true);
		wire.eventMouseClick.subscribe(wireClick, wire, true);
		</pre>
		
	</li>
	<li>
		<p>Override Wire.prototype methods</p>
		<pre class="brush:js">
			Wire.prototype.onWireIn = function(x,y) {
			};
			
			Wire.prototype.onWireOut = function(x,y) {
			};
			
			Wire.prototype.onWireClick = function(x,y) {
			};
		</pre>
	</li>
</ul>


<p>Here is an example to create a random layer and lister for wire events :</p>

<pre class="brush:js">
	
	// Functions executed with the scope of a wire
	var wireRed = function() {
			this.options.color = 'rgb(255, 0, 0)';
	  		this.redraw();
		},
		wireBlue = function() {
			this.options.color = 'rgb(173, 216, 230)';
			this.redraw();
		},
		wireClick = function() {
			alert("Hoho ! you clicked !");
		};
	
	// Generate a random layer
	var layer = new WireIt.Layer({});
	for(var i = 0 ; i &lt; 5 ; i++) {
		layer.addContainer({
			terminals: [ {direction: [0,1], offsetPosition: {bottom: -13, left: 25} }],
			title: "Block #"+i,
			position: [ Math.floor(Math.random()*800)+30, Math.floor(Math.random()*300)+30 ]
		});
	}
	
	for(var i = 0 ; i &lt; 7 ; i++) {
	
		var w = layer.addWire({
			src: {moduleId: Math.floor(Math.random()*5), terminalId: 0},
			tgt: {moduleId: Math.floor(Math.random()*5), terminalId: 0}
		});
	
		// Subscribe methods to mouse events for all wires
		w.eventMouseIn.subscribe(wireRed, w, true);
		w.eventMouseOut.subscribe(wireBlue, w, true);
		w.eventMouseClick.subscribe(wireClick, w, true);
	}
</pre>



<a name="createContainers"><h2>Creating new Containers / Extending existing containers</h2></a>

<p>The general way to create a new <i>Container</i> class is to extend the WireIt.Container class. We do this YUI-style :</p>

<pre class="brush:js">
	WireIt.MyContainer = function(options, layer) {
	   WireIt.MyContainer.superclass.constructor.call(this, options, layer);
	};
	YAHOO.lang.extend(WireIt.MyContainer, WireIt.Container, {
		// override methods or new methods
	});
</pre>

<p>You can extend from WireIt.Container, WireIt.InOutContainer, WireIt.ImageContainer, WireIt.FormContainer.</p>

<p>For more details with Container methods, please refer to the API Documentation.</p>

<p>To extend or modify the behavior of an existing Container.</p>

<pre class="brush:js">
WireIt.ImageContainer.prototype.myMethod = function () {
	// new code
};
</pre>

<p>To use your new Container in a language definition go to <a href="#moduleDefinition">Module Definition</a>.</p>




<a name="production"><h2>notes on production</h2></a>

<p>In a production environment, it is preferable to use rollup files: The javascript files are concatenated into a single javascript file (to reduce the number of HTTP requests) then compressed using the YUI compressor (to reduce file size).</p>

<p>Some rollup files are provided in the <i>wireit/build</i> directory :</p>

<pre class="brush:html">
	&lt;script type="text/javascript" src="lib/wireit/build/wireit-min.js"&gt;&lt;/script&gt;
</pre>

<p>or</p>

<pre class="brush:html">
	&lt;script type="text/javascript" src="lib/wireit/build/wiring-editor-min.js"&gt;&lt;/script&gt;
</pre>

<p><u>Warning :</u>The rollup files <b>don't</b> include the excanvas.js library <b>required by Internet Explorer</b>, because this file is conditionally loaded using the "if IE" hack :</p>

<pre class="brush:html">
	&lt;!--[if IE]&gt;&lt;script type="text/javascript" src="../../lib/excanvas.js"&gt;&lt;/script&gt;&lt;![endif]--&gt;
</pre>

<p><u>Warning :</u>The wiring-editor-min.js file <b>doesn't</b> include any adapter, and only includes <b>some</b> fields of the inputEx library.</p>

<p class="advanced">It is strongly recommended to build your custom rollup file for production. You can then include the adapter you use, the visual language definition, or even the YUI library dependencies. The script to build those files is available at build/rollups.sh (only in source, not in the zipped library)</p>

<p class="advanced">The YUI library is included in the zip file, but the YUI files can be served from Yahoo or Google servers.</p>

<p>Moreover, the WireIt zip file contains example, guides, documentation, which are not necessary in a production environment. We recommend you to copy only the required files on your webserver :</p>

<pre>
	wireit/
 	 - build/
 	 - css/
 	 - images/
 	 - js/
 	 - lib/
</pre>










<a name="moreInformation"><h1>More information</h2></a>




<a name="examples"><h2>All examples</h2></a>
	<ul>
		<li><a href="examples/presentation.html">Interactive presentation</a></li>
		<li><a href="examples/creating_terminals.html">Creating terminals and wires</a></li>
		<li><a href="examples/changing_directions.html">Changing terminal direction</a></li>
		<li><a href="examples/wires_and_terminals.html">Wire and Terminals configuration</a></li>
		<li><a href="examples/dd_and_animation.html">Using animation</a></li>
		<li><a href="examples/planarGame/planarGame.html">Planar game</a></li>
		<li><a href="examples/inputex/">FormContainers</a></li>
	</ul>
	
	<p>WiringEditor :</p>
	<ul>
		<li><a href="examples/WiringEditor/">WiringEditor demo</a></li>
		<li><a href="examples/jsBox/jsBox.html">jsBox</a></li>
		<li><a href="examples/logicGates/index.html">Logic Gates demo</a></li>
		<li><a href="examples/ajaxAdapter/">Ajax Adapter</a></li>
		<li><a href="examples/gearsAdapter/">Gears Adapter</a></li>
	</ul>
	
	<p>Beta/Experimental :</p>
	<ul>
		<li><a href="examples/wire_events.html">Wire mouse events</a></li>
		<li><a href="examples/wire_tooltips.html">Wire context menu</a></li>
		<li><a href="examples/spring_layout.html">Spring Layout</a></li>
		<li><a href="examples/dotparser/">Dot parser</a></li>
	</ul>






<a name="apiReferences"><h2>API References</h2></a>

<p><a href="doc/index.html" style="font-size: 130%;">WireIt API Documentation</a></p>

<p>Deeper hacking into WireIt might require some knowledge in the libraries used :</p>
	
<ul class="secondLevel">
	<li><a href="http://javascript.neyric.com/inputex/">inputEx Documentation</a></li>
	<li><a href="http://developer.yahoo.com/yui/">YUI Documentation</a></li>
	<li><a href="http://www.i-marco.nl/weblog/yui-accordion/">yui-accordion</a></li>
</ul>


<a name="otherResources"><h2>Other resources</h2></a>
		
<ul>
	<li>You can get some help on the <a href="http://groups.google.com/group/wireit/">forum</a>.</li>
	<li><a href="http://javascript.neyric.com/wireit/">Project home page</a></li>
	<li><a href="http://github.com/neyric/wireit">Source code repository</a> on GitHub</li>
	<li><a href="http://github.com/neyric/wireit/issues">Issue tracker</a></li>
	<li><a href="http://javascript.neyric.com/blog/category/wireit/">WireIt Blog</a></li>
	<li><a href="http://wiki.github.com/neyric/wireit">Wiki</a></li>
	<li><a href="http://twitter.com/wireit">WireIt changelog on twitter</a></li>
</ul>
			
<a name="projects"><h2>WireIt-based projects</h2></a>

<ul>
	<li><a href="http://tarpipe.com">Tarpipe</a> - share content across social applications</li>
	<li><a href="http://github.com/LeifW/pipescape/tree/master">Pipescape</a> - a WireIt interface to <a href="http://www.w3.org/TR/xproc/">XProc</a></li>
	<li><a href="http://graphpipes.de/">Graphpipes</a> - easy way to aggregate semantic data</li>
</ul>

<p>Email me your own: &lt;eric.abouaf at gmail&gt;</p>






<a name="contribute"><h2>Contribute</h2></a>

<p>You can contribute in a lot of different ways :</p>

<ul>
	<li>Design/Styling - images or css</li>
	<li>Adapters/backend code</li>
	<li>write new examples</li>
	<li>improve documentation</li>
	<li>core contributions (see the <a href="#roadmap">roadmap</a>)</li>
</ul>

<p>If you use this project in a commercial application, or simply wish to see this project continue, you can donate on PayPal. Donations will be used for WireIt development and promotion.</p>
	
	<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
	<input type="hidden" name="cmd" value="_s-xclick">
	<input type="hidden" name="encrypted" value="-----BEGIN PKCS7-----MIIHTwYJKoZIhvcNAQcEoIIHQDCCBzwCAQExggEwMIIBLAIBADCBlDCBjjELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNBMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKEwtQYXlQYWwgSW5jLjETMBEGA1UECxQKbGl2ZV9jZXJ0czERMA8GA1UEAxQIbGl2ZV9hcGkxHDAaBgkqhkiG9w0BCQEWDXJlQHBheXBhbC5jb20CA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OQzea0NXe1nq514iv3a6jHVyEupTZ/D8IH3kN29XGYjy0PVuDsr3hFxKAxoPdf2wjVhGauFSAxxFTTsfscWyoh99U11n0+s-----END PKCS7-----
	">
	<input type="image" src="https://www.paypal.com/en_US/i/btn/btn_donate_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
	<img alt="" border="0" src="https://www.paypal.com/fr_FR/i/scr/pixel.gif" width="1" height="1">
	</form>




	<a name="roadmap"><h2>Roadmap</h2></a>

	<p>Here is a list of the main requested features. Please note that this is a wish-list, it's not always what the developers are currently working on.</p>

	<ul>
		<li>
			<b>Improve Layout</b>
			<p>WireIt has proven useful for graph editing, but it is also very good at data visualization.<br />
			   However, the current layout engine still has a long way to go...</p>
		</li>
		<li>
			<b>Wire labels/properties</b>
			<p>Adding labels to the wires. This will now be easier thanks to the <a href="http://code.google.com/p/canvas-text/">Canvas-Text library</a>.</p>
		</li>
		<li>
			<b>Improve the WiringEditor</b>
			<p>Keep improving this strong application framework.</p>
		</li>
		<li>
			<b>Progressive enhancement</b>
			<p>The idea is to generate containers/terminals/wires from existing HTML. This is especially useful for <i>wirings</i> to be <b>indexable by search engines</b>.</p>
		</li>
		<li>
			<b>Provide more backends/adapters</b>
			<p>New backends/code generators to increase development speed. <br />
			 Although the backend largely depends on your project, it would be nice to have one for each major framework: <b>Rails, Django, Symfony, AppEngine, ...</b></p>
		</li>
	</ul>



<!-- END OF THE GUIDE -->












				
</div>

<div style="font-size: 8pt; color: #999999; background-color: #222222; border-top: 2px solid black; padding: 10px; margin-top: 20px;">
	
	<ul class="navigation">
		<li><a href="index.html">Home</a></li>	
		<li><a href="http://github.com/neyric/wireit/">GitHub[Git]</a></li>
		<li><a href="http://github.com/neyric/wireit/issues">Issues</a></li>
		<li><a href="guide.html">Guide</a></li>		
		<li><a href="doc/index.html">API Documentation</a></li>		
		<li><a href="http://javascript.neyric.com/blog/category/wireit/">Blog</a></a></li>	
		<li><a href="http://groups.google.com/group/wireit/">Forums</a></li>
	</ul>
	
	<p style="font-size: 90%; margin-top: 20px;">WireIt is released under the <a href="license.txt" style="color: white;">MIT license</a>.</p>
</div>

</center>

<script type="text/javascript">
document.write(unescape("%3Cscript src='http://www.google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-567557-2");
pageTracker._trackPageview();
</script>

 </body>
</html>